<template>
  <!-- 精选题库 -->
  <div class="container">
    <el-form
      :inline="true"
      :model="formInline"
      class="demo-form-inline"
      label-position
    >
      <el-row>
        <el-col :span="24" :push="22">
          <el-form-item>
            <el-button
              type="success"
              size="small"
              icon="el-icon-edit"
              @click="onSubmit"
              >新增技巧</el-button
            >
          </el-form-item>
        </el-col>
        <el-col :span="6" align="center">
          <el-form-item label="学科">
            <el-select
              v-model="formInline.region"
              size="small"
              placeholder="请选择"
            >
              <el-option label="启用" value="shanghai"></el-option>
              <el-option label="禁用" value="beijing"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="二级目录">
            <el-select
              v-model="formInline.region"
              size="small"
              placeholder="请选择"
            >
              <el-option label="启用" value="shanghai"></el-option>
              <el-option label="禁用" value="beijing"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="标签">
            <el-select
              v-model="formInline.region"
              size="small"
              placeholder="请选择"
            >
              <el-option label="启用" value="shanghai"></el-option>
              <el-option label="禁用" value="beijing"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="关键字">
            <el-select
              v-model="formInline.region"
              size="small"
              placeholder="根据题干搜索"
            >
              <el-option label="启用" value="shanghai"></el-option>
              <el-option label="禁用" value="beijing"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6" align="center">
          <el-form-item label="试题类型">
            <el-select
              v-model="formInline.region"
              size="small"
              placeholder="请选择"
            >
              <el-option label="启用" value="shanghai"></el-option>
              <el-option label="禁用" value="beijing"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="难度">
            <el-select
              v-model="formInline.region"
              size="small"
              placeholder="请选择"
            >
              <el-option label="启用" value="shanghai"></el-option>
              <el-option label="禁用" value="beijing"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="方向">
            <el-select
              v-model="formInline.region"
              size="small"
              placeholder="请选择"
            >
              <el-option label="启用" value="shanghai"></el-option>
              <el-option label="禁用" value="beijing"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="录入人">
            <el-select
              v-model="formInline.region"
              size="small"
              placeholder="请选择"
            >
              <el-option label="启用" value="shanghai"></el-option>
              <el-option label="禁用" value="beijing"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6" align="center">
          <el-form-item label="题目备注">
            <el-input v-model="formInline.name" size="small"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="企业简称">
            <el-input v-model="formInline.name" size="small"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="状态">
            <el-select
              v-model="formInline.region"
              placeholder="请选择活动区域"
              size="small"
              style="width: 100px"
            >
              <el-option label="区域一" value="shanghai"></el-option>
              <el-option label="区域二" value="beijing"></el-option>
            </el-select>
            <el-select
              v-model="formInline.region"
              placeholder="请选择活动区域"
              size="small"
              style="width: 100px"
            >
              <el-option label="区域一" value="shanghai"></el-option>
              <el-option label="区域二" value="beijing"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6" align="left" :push="2">
          <el-form-item>
            <el-button size="small" @click="onSubmit">清除</el-button>
            <el-button type="primary" size="small" @click="onSubmit"
              >查询</el-button
            >
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div class="record">
      <i class="el-icon-info"></i>
      <span>数据一共 {{ counts }} 条</span>
    </div>

    <el-table :data="tableData" style="width: 100%">
      <el-table-column prop="id" label="试题编号"> </el-table-column>
      <el-table-column prop="" label="学科"> </el-table-column>
      <el-table-column prop="catalogID" label="目录"> </el-table-column>
      <el-table-column prop="questionType" label="题型"> </el-table-column>
      <el-table-column prop="" label="题干" align="center"> </el-table-column>
      <el-table-column prop="addDate" label="录入时间" align="center">
      </el-table-column>
      <el-table-column
        prop="permission_group_title"
        label="难度"
        align="center"
      >
      </el-table-column>
      <el-table-column prop="creator" label="录入人" align="center">
      </el-table-column>
      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="primary"
            plain
            circle
            @click="handleEdit(scope.row)"
            icon="el-icon-edit"
            v-show="scope.row.username !== '超级管理员'"
          ></el-button>
          <el-button
            size="mini"
            type="danger"
            plain
            circle
            @click="handleDelete(scope.row)"
            icon="el-icon-delete"
            v-show="scope.row.username !== '超级管理员'"
          ></el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-row>
      <el-col :push="13">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="formList.page"
          :page-sizes="[10, 20, 30, 50]"
          :page-size="formList.pagesize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="counts"
        >
        </el-pagination>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { list } from '@/api/hmmm/questions.js'
import moment from 'moment'
export default {
  data () {
    return {
      options: [],
      value: '',
      counts: 1,
      formInline: {
        user: '',
        region: ''
      },
      formList: {
        page: 1,
        pagesize: 10
      },
      tableData: []
    }
  },
  created () {
    this.getList()
  },
  methods: {
    onSubmit () {
      console.log('submit!')
    },
    async getList () {
      const { data } = await list(this.formList)
      console.log(data)
      this.tableData = data.items
      this.tableData.forEach(item => {
        item.addDate = moment(item.addDate).format('YYYY-MM-DD HH:mm:ss')
      })
      this.counts = data.counts
    },
    handleSizeChange (val) {
      this.formList.page = 1
      this.formList.pagesize = val
      this.getList()
    },
    handleCurrentChange (val) {
      this.formList.page = val
      this.getList()
    },
    // TODO
    handleChange () {}
  }
}
</script>

<style scoped lang="less">
/deep/ .el-col {
  z-index: 99;
  padding: 0;
  margin: 0;
}
.record {
  width: 1280px;
  height: 40px;
  border-radius: 4px;
  line-height: 40px;
  margin: 0 auto;
  background-color: #f4f4f5;
  font-size: 14px;
  color: #ccc;
  span {
    margin-left: 10px;
  }
  .el-icon-info {
    font-size: 15px;
    color: #909399;
    margin-left: 15px;
  }
}
.el-col {
  margin-top: 20px;
}
.container {
  width: 1320px;
  margin: 10px auto;
  background-color: #fff;
  border-radius: 5px;
}
</style>
